//
//  STEntryProcessTableViewCell.swift
//  SeaTransportManage
//
//  Created by guopengwen on 2021/11/27.
//

import UIKit

class STEntryProcessTableViewCell: UITableViewCell {

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        backgroundColor = UIColor.init(hexString: "#FFFFFF", alpha:0)
        selectionStyle = .none
        
        let bg_view: UIView = UIView.init(frame: CGRect.zero)
        bg_view.layer.cornerRadius = 12
        bg_view.backgroundColor = UIColor.white
        contentView.addSubview(bg_view)
        bg_view.snp.makeConstraints { (make) in
            make.top.equalTo(0)
            make.left.equalTo(16)
            make.right.equalTo(-16)
            make.bottom.equalTo(-16)
        }
        
        bg_view.addSubview(iconView)
        iconView.snp.makeConstraints { (make) in
            make.centerY.equalTo(bg_view.snp.centerY)
            make.left.equalTo(16)
            make.width.equalTo(74)
            make.height.equalTo(74)
        }
    
        
        bg_view.addSubview(descLabel)
        descLabel.snp.makeConstraints { (make) in
            make.centerY.equalTo(iconView.snp.centerY)
            make.left.equalTo(iconView.snp.right).offset(9)
            make.height.equalTo(28)
        }
        
        let imgView = UIImageView.init(image: UIImage.init(named: "icon_paizao"))
        bg_view.addSubview(imgView)
        imgView.snp.makeConstraints { (make) in
            make.centerY.equalTo(self)
            make.right.equalTo(-24)
            make.width.equalTo(42)
            make.height.equalTo(42)
        }
        
        iconView.image = UIImage.init(named: "icon_luozhong")
    }
    
    public func updateValue(title: String, indexPath: IndexPath) {
        descLabel.text = title
        
        var str = ""
        if (indexPath.section == 0) {
            if(indexPath.row == 0) {
                str = "img_tixiang"
            } else if(indexPath.row == 1) {
                str = "icon_zhuangxiang"
            } else {
                str = "icon_luozhong"
            }
        } else {
            if(indexPath.row == 0) {
                str = "img_tixiang"
            } else if(indexPath.row == 1) {
                str = "img_zhuangxiang"
            } else {
                str = "icon_luozhong"
            }
        }
        iconView.image = UIImage.init(named: str)
    }
    
    lazy var iconView: UIImageView = {
        let imgView = UIImageView.init()
        return imgView
    }()
    
    
    lazy var descLabel: UILabel = {
        let lb = UILabel.init()
        lb.font = UIFont.systemFont(ofSize: 18, weight: UIFont.Weight.heavy)
        lb.textAlignment = .center
        return lb
    }()
    
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        
    }

}
